package com.annotation.validator;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

public abstract class FieldValidatorSupport extends WebValidateErrors implements Validator {


	private String fieldName;
	
	private String message;
	
	public String getFieldName() {
		return fieldName;
	}

	public void setFieldName(String fieldName) {
		this.fieldName = fieldName;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	/**
	 * 获取客户端请求
	 * @return
	 */
	private  HttpServletRequest get(){
		ServletRequestAttributes requestAttributes=(ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
		return requestAttributes.getRequest();
	}
	
	public String getFieldValue(){
		HttpServletRequest request=get();
	    return request.getParameter(this.getFieldName());
	}

}
